<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item v-for="(item) in breadList" :key="item.path" :to="{ path: item.path }">
        <span>
          {{ item.meta.title }}
        </span>
      </el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script>
export default {
  name: "HealthVuebackstageBreadcrumbview",

  data() {
    return {
      breadList: [],
    };
  },
  watch: {
    $route() {
      this.getBreadcrumb();
    },
  },

  mounted() {},

  methods: {
    isHome(route) {
      return route.name === "HomeView";
    },
    getBreadcrumb() {
      let matched = this.$route.matched;
      if (!this.isHome(matched[0])) {
        matched = [{ path: "/home", meta: { title: "首页" } }].concat(matched);
      }
      this.breadList = matched;
    },
  },
  created() {
    this.getBreadcrumb();
  },
};
</script>

<style lang="scss" scoped>
</style>